# coding=utf-8

import requests
from config import BaseConfig
from app.extensions import log


def sendMail(_to = None, _subject = None, _body = None):
    """
    发送邮件
    :param _to: 接受人
    :param _subject: 主题
    :param _body: 邮件内容
    :return:
    """
    log.info("app.modules.common.mailUtil.sendMail to=%s. subject=%s. body=%s" % (_to, _subject, _body))
    if not BaseConfig.SEND_MAIL_FLAG:
        log.info('app.modules.common.mailUtil.sendMail flag is false')
        return
    _data = {'to': _to, 'subject': _subject, 'body': _body}
    _rtn = requests.post(url = BaseConfig.UPUSH_URL, json = _data).content
    log.info('app.modules.common.mailUtil.sendMail rtn is %s . data is %s' % (_rtn, _data))
